package com.clarence.dada.modular.system.app.controller;


import com.clarence.dada.core.base.PageResult;
import com.clarence.dada.core.base.Result;
import com.clarence.dada.modular.system.app.entity.req.SysAppReq;
import com.clarence.dada.modular.system.app.entity.resp.SysAppResp;
import com.clarence.dada.modular.system.app.service.SysAppService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统应用控制器
 *
 * @author GD
 * @since 2020/3/20 21:25
 */
@RestController
@RequestMapping("/system/sysApp/")
@Tag(name = "应用管理", description = "应用管理Controller")
public class SysAppController {

    @Resource
    private SysAppService sysAppService;

    /**
     * 添加系统应用
     *
     * @author GD
     * @since 2020/3/25 14:44
     */
    @Operation(summary = "系统应用_新增", description = "新增应用")
    @PostMapping("appAdd")
    public Result<Void> appAdd(@RequestBody @Validated(SysAppReq.add.class) SysAppReq req) {
        sysAppService.appAdd(req);
        return Result.SUCCESS;
    }

    /**
     * 删除系统应用
     *
     * @author GD
     * @since 2020/3/25 14:54
     */
    @Operation(summary = "系统应用_删除", description = "删除应用")
    @PostMapping("appDelete")
    public Result<Void> appDelete(@RequestBody @Validated(SysAppReq.delete.class) SysAppReq sysAppReq) {
        sysAppService.appDelete(sysAppReq);
        return Result.SUCCESS;
    }

    /**
     * 编辑系统应用
     *
     * @author GD
     * @since 2020/3/25 14:54
     */
    @Operation(summary = "系统应用_编辑", description = "编辑应用")
    @PostMapping("appEdit")
    public Result<Void> appEdit(@RequestBody @Validated(SysAppReq.edit.class) SysAppReq sysAppReq) {
        sysAppService.appEdit(sysAppReq);
        return Result.SUCCESS;
    }

    /**
     * 修改应用状态
     *
     * @author GD
     * @since 2020/6/29 16:49
     */
    @Operation(summary = "系统应用_修改显示状态", description = "修改应用显示状态")
    @PostMapping("appUpdateStatus")
    public Result<Void> appUpdateStatus(@RequestBody @Validated(SysAppReq.updateStatus.class) SysAppReq sysAppReq) {
        sysAppService.appUpdateStatus(sysAppReq);
        return Result.SUCCESS;
    }

    /**
     * 查看系统应用
     *
     * @author GD
     * @since 2020/3/26 9:49
     */
    @Operation(summary = "系统应用_查看", description = "查看应用")
    @GetMapping("appDetail")
    public Result<SysAppResp> appDetail(@Validated(SysAppReq.detail.class) SysAppReq sysAppReq) {
        return new Result<>(sysAppService.appDetail(sysAppReq));
    }

    /**
     * 系统应用下拉列表（菜单查询列表筛选条件下拉）
     *
     * @author GD
     * @since 2020/4/19 14:55
     */
    @Operation(summary = "系统应用_列表（下拉）", description = "应用列表（下拉）")
    @GetMapping("appDropDown")
    public Result<List<SysAppResp>> appDropDown(SysAppReq sysAppReq) {
        return new Result<>(sysAppService.appDropDown(sysAppReq));
    }

    /**
     * 查询系统应用
     *
     * @author GD
     * @since 2020/3/20 21:23
     */
    @Operation(summary = "系统应用_查询列表(分页)", description = "应用查询列表(分页)")
    @GetMapping("appPage")
    public Result<PageResult<SysAppResp>> appPage(SysAppReq sysAppReq) {
        return new Result<>(sysAppService.appPage(sysAppReq));
    }

    /**
     * 将应用设为默认应用，用户进入系统会默认进这个应用的菜单
     *
     * @author GD
     * @since 2020/6/29 16:49
     */
    @Operation(summary = "系统应用_设为置顶", description = "设为置顶应用")
    @PostMapping("appSetTop")
    public Result<Void> appSetTop(@RequestBody @Validated(SysAppReq.appSetTop.class) SysAppReq sysAppReq) {
        sysAppService.appSetTop(sysAppReq);
        return Result.SUCCESS;
    }

    /**
     * 获取应用列表，用于顶部应用列表
     *
     * @author GD
     * @since 2021/4/21 15:31
     */
    @Operation(summary = "系统应用_用户顶部列表", description = "获取用户顶部应用列表，用于顶部应用列表")
    @GetMapping("getUserTopAppList")
    public Result<List<SysAppResp>> getUserTopAppList() {
        return new Result<>(sysAppService.getUserTopAppList());
    }

}
